import http from "./request"

// 登录接口
export const loginApi = (username, password) => {
    return http({
        method: 'POST',
        url: 'http://localhost:12345/api/user/login',
        data: { username, password }
    });
}

// 注册接口
export const registerApi = (username, password) => {
    return http({
        method: 'POST',
        url: 'http://localhost:12345/api/user/register',
        data: { username, password }
    });
}

// 导航菜单接口
export const catitemsApi = () => {
    return http({
        method: 'GET',
        url: 'https://api-hmugo-web.itheima.net/api/public/v1/home/catitems',
        params: {}
    });
}

// 商品列表搜索
export const searchApi = (query, pagenum, pagesize = 20) => {
    return http({
        method: 'GET',
        url: 'https://api-hmugo-web.itheima.net/api/public/v1/goods/search',
        params: { query, pagenum, pagesize }
    });
}

// 商品分类
export const categoriesApi = () => {
    return http({
        method: 'GET',
        url: 'https://api-hmugo-web.itheima.net/api/public/v1/categories',
        params: {}
    });
}

// 商品详情
export const detailApi = (goods_id) => {
    return http({
        method: 'GET',
        url: 'https://api-hmugo-web.itheima.net/api/public/v1/goods/detail',
        params: { goods_id }
    });
}

// 商品详情
export const swiperdataApi = () => {
    return http({
        method: 'GET',
        url: 'https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata',
        params: {}
    });
}
